package com.iman.Confucius.service.impl.student;

import java.util.HashMap;
import java.util.Map;

import javax.inject.Inject;

import org.springframework.stereotype.Service;

import com.iman.Confucius.service.student.MyExamService;
import com.iman.Confucius.vo.student.MyTestVo;
import com.iman.common.hibernate.HibernateSupport;
import com.iman.common.hibernate.TemplateQLService;
import com.iman.common.support.Page;

@Service("testService")
public class MyExamServiceImpl implements MyExamService{

	public static Integer Done =1;
	public static Integer Doing =0;
	
	@Inject
    TemplateQLService templateQLService;

    @Inject
    HibernateSupport  hibernateSupport;
	
	
	
	/*
	 * (non-Javadoc)
	 * @see com.iman.Confucius.service.student.TestService#listPerpareTest(java.lang.Long, int, int)
	 */
    @Override
	public Page<MyTestVo> listPerpareTest(Long userId,int pageNo, int size) {

		Map params = new HashMap();
		params.put("ownerId", userId);
		params.put("doneYn",Doing  );
		return query(   params ,  pageNo,   size  );
	}

	 
	@Override
	/**
	 * 
	 */
	public Page<MyTestVo> listReadyTest(Long userId,int pageNo, int size) {
		 
		Map params = new HashMap();
		params.put("ownerId", userId);
		params.put("doneYn", Done);
		return query(   params ,  pageNo,   size  );
		 
	}
	
	/**
	 * 
	 *  Function:
	 *  功能说明：内部查询
	 *	 使用说明：
	 *  @author  wangxiaolei  DateTime 2015年1月8日 上午2:17:36
	 *	返回类型: Page<MyTestVo>    
	 *  @param params
	 *  @param pageNo
	 *  @param size
	 *  @return
	 */
	private Page<MyTestVo> query( Map params ,int pageNo, int size  ){
		return templateQLService.findByPagedSQLBeanQuery(
				"get_mytest_list", params , Page.getStartOfPage(pageNo, size), size,
				MyTestVo.class);
	}

	

	 
}
